package com.itlaobing.tracing.cookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/cookie/receiver")
public class CookieReceiveServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.log("cookie 测试");

        String cookies = request.getHeader("cookie");
        this.log(cookies);

        Cookie[] cookieArray = request.getCookies();
        if (cookieArray != null){
            for (int i = 0; i < cookieArray.length; i++) {
                Cookie ck = cookieArray[i];
                System.out.println( ck.getName() + " : " + ck.getValue() + " ==> " + ck.getDomain() + "," + ck.getPath() );
            }

        }
    }
}
